// OddTask.java
package com.itheima.xiancheng;

class OddTask implements Runnable {
    @Override
    public void run() {
        // 打印1-100之间的所有奇数
        for (int i = 1; i <= 100; i += 2) {
            System.out.println(Thread.currentThread().getName() + "打印: " + i);
            try {
                // 每个数字之间暂停10毫秒
                Thread.sleep(10);
            } catch (InterruptedException e) {
                // 处理InterruptedException异常
                e.printStackTrace();
            }
        }
    }
}


class EvenTask implements Runnable {
    @Override
    public void run() {
        // 打印1-100之间的所有偶数
        for (int i = 2; i <= 100; i += 2) {
            System.out.println(Thread.currentThread().getName() + "打印: " + i);
            try {
                // 每个数字之间暂停15毫秒
                Thread.sleep(15);
            } catch (InterruptedException e) {
                // 处理InterruptedException异常
                e.printStackTrace();
            }
        }
    }
}



